package org.example.myleet.p876;

import org.example.myleet.Utils.ListNode;

public class Solution {
    /**
     * 思路：快慢指针，快指针比慢指针多跑一半距离
     */
    public ListNode middleNode(ListNode head) {
        ListNode fast = head, slow = head;
        while (fast.next != null) {
            slow = slow.next;
            fast = fast.next;
            if (fast.next != null) {
                fast = fast.next;
            }
        }
        return slow;
    }
}
